avatar

Exception in thread main io.jsonwebtoken.ExpiredJwtException JWT expired at 2020-04-07T16 33 30Z. Current time 2020-04-07T16 33 37Z, a difference of 7471 milliseconds. Allowed clock skew 0 milliseconds

异常信息

1
2
3
4
5
Exception in thread "main" io.jsonwebtoken.ExpiredJwtException: JWT expired at 2020-04-07T16:33:30Z. Current time: 2020-04-07T16:33:37Z, a difference of 7471 milliseconds.  Allowed clock skew: 0 milliseconds.
at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:385)
at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:481)
at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:541)
at aa.main(aa.java:24)

异常原因

1
令牌过期

异常代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public static void main(String[] args) {

/* 生成jwt令牌 */
String compact = Jwts.builder()
.setId("1234")
.setSubject("123")
.setIssuedAt(new Date())
/* 令牌过期时间 */
.setExpiration(new Date())
.signWith(SignatureAlgorithm.HS256, "1234").compact();

System.out.println(compact);

/* jwt令牌解析 */
System.out.println(Jwts.parser().setSigningKey("1234").parseClaimsJws(compact).getBody());

}
文章作者: 123
文章链接: https://gao5805123.github.io/123/2020/05/04/Exception%20in%20thread%20main%20io.jsonwebtoken.ExpiredJwtException%20JWT%20expired%20at%202020-04-07T16%2033%2030Z.%20Current%20time%202020-04-07T16%2033%2037Z,%20a%20difference%20of%207471%20milliseconds/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 123
打赏
  • 微信
    微信
  • 支付宝
    支付宝